package edu.pku.sei.act.sampletask;

import edu.pku.sei.act.actools.util.AbilityOutput;
import edu.pku.sei.act.actools.util.TaskMessage;
import edu.pku.sei.act.sampletask.car._Car;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.RemoteException;
import android.util.Log;

public class AutonomicParkingReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		Log.v("@jjj", "AutonomicParkingReceiver!");
		String rs = (String) intent.getExtras().get("arg1");
		TaskMessage msg = new TaskMessage(rs);
		if (msg.getContent().equals("Car")) {
			try {
				_Car.capability.START_OUTPUT = new AbilityOutput(AutonomicParking.getCm().invokeCapability(_Car.capability._START, null));
				_Car.capability.STOP_OUTPUT = new AbilityOutput(AutonomicParking.getCm().invokeCapability(_Car.capability._STOP, null));
				AutonomicParking.setState(_Car.state.PREPARE_TO_ENTER);
			} catch (RemoteException e1) {
				e1.printStackTrace();
			}
		}
		else {
			
		}
	}

}
